<template>

	<div class="setLogin">
		<yd-cell-item class="my-cell-item" arrow type="link" href="/loginModjpass">
			<span slot="left">修改登录密码</span>
			<span slot="right"></span>
		</yd-cell-item>
		<yd-cell-item class="my-cell-item" arrow type="link" href="/aboutwe">
			<span slot="left">关于住多多</span>
			<span slot="right"></span>
		</yd-cell-item>
		<div class="outlogin" @click="outlogin">
			退出
		</div>
	</div>
</template>

<script>
	import { mapGetters, mapActions } from 'vuex'
	import  api from '../fetch/api'
	export default {
		name: 'loginSet',
		data() {
			return {
				getHiss: JSON.parse(sessionStorage.getItem("userinfo")),
				source: "web",
			}
		},
		mounted() {
			var that = this;
			if (that.userstatus) {
				that.userId =that.userinfo.id;
				that.token = that.userinfo.token;
			}else{
				that.$router.push({
					path: "/login"
				})
			}
		},
		computed: {
			...mapGetters([
				'userinfo',
				'userstatus'
			])},
		methods: {
			...mapActions({
				setUserInfo:'setUserInfo',
				setUsersta:'setUsersta',
				baseInfodata:'baseInfodata'
			}),
			outlogin() {

				var that = this;
				let ajaxSign = {
					"source": that.source,
					"token": that.getHiss.token,
					"userId": that.getHiss.id.toString()
				};
				let ajaxData = api.getAES(ajaxSign);
				//				数据调用
				api.GetLoginOut(ajaxData)
				.then(res => {
					that.$dialog.toast({
						mes: res.msg,
						timeout: 1000
					})
					if(res.sta == 200) {
						that.setUserInfo(false);
						that.setUsersta(false);
						sessionStorage.removeItem("userinfo")
						sessionStorage.removeItem("baseInfodata")
						that.baseInfodata(null)
						that.$router.push({
							path: "/login"
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.setLogin{
		background: #EEEEEE;
	}
	.my-cell-item {
		border-bottom: 1px solid #eeeeee;
		font-size: .31rem;
		color: #282828;
		background: #fff;
	}
	
	.setLogin .yd-cell-item:not(:last-child):after {
		display: none;
	}
	
	.outlogin {
		width: 100%;
		font-size: .31rem;
		color: #e34648;
		text-align: center;
		height: 1rem;
		line-height: 1rem;
		margin-top: .1rem;
		background: #fff;
	}
</style>